<template>
	<view>
		<view class="center">
			<view class="search ">
				<view class="search_head">
					<view class="search_icon">
						<uni-icons type="search" color="#a1a5a7" size="30rpx"></uni-icons>
					</view>
					<view class="search_inp">
						<input type="text" placeholder="搜索商品" />
					</view>
				</view>
			</view>
		</view>
		<view class="center">
			<view class=" activity ">
				<view class="activity_icon">
					<view class="activity_icon_backgreen">
						<uni-icons class="icons" type="heart-filled" color="#fff" size="30rpx"></uni-icons>
					</view>
				</view>
				<view class="activity_body">
					<view class="activity_left">
						秋日限定:储值300元，立赠1杯
					</view>
					<view class="activity_right">
						<view class="">
							查看等多
						</view>
						<view class="">
							<uni-icons type="right" color="#4f4d4d" size="23rpx"></uni-icons>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="center">
			<view class="milky">
				<view class="milky_title" >
					<view :class=" sign==index? 'che':'tab' "  @click=" tabqh(index) " v-for="(item,index) in productlist" :key="index">
						{{item.name}}
						<view class="tag" v-if=" item.tag">
							{{item.tag}}
						</view>
					</view>
					
				</view>
				<view class="milky_body">
					<view class=" slideshow ">
						<swiper class="swiper":indicator-dots="indicatorDots" :autoplay="autoplay"
							:interval="interval" :duration="duration">
							<swiper-item>
								<view class="swiper-item uni-bg-red"> <image class="slideshow_img" src="../../static/images/1634883391623.jpg" mode=""></image> </view>
							</swiper-item>
							<swiper-item>
								<view class="swiper-item uni-bg-green"> <image class="slideshow_img" src="../../static/images/1636038401741.jpg" mode=""></image></view>
							</swiper-item>
							<swiper-item>
								<view class="swiper-item uni-bg-blue"> <image class="slideshow_img" src="../../static/images/1636038821602.png" mode=""></image></view>
							</swiper-item>
						</swiper>
					</view>
					<view class="milky_content">
						<view class="milky_body_head">
							当季限定
						</view>
						<view class="milky_body_content" v-for="(item,index) in products" :key="index">
							<view class="milky_body_content_img">
								<image :src="item.pic" mode=""></image>
							</view>
							<view class="introduce" >
								<view class="name">
									{{item.name}}
								</view>
								<view class="label" >
									<view class="pink" v-for="(ite,inde) in products[index].tags">
										{{ite}}
									</view>
								</view>
								<view class="particulars">
									{{item.detail}}
								</view>
								<view class="plus">
									<view class="num">
										¥{{item.price}}.00
									</view>
									<view class="jia">
										+
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				productlist:[],
				sign:0,
				products:[],
				tags:[]
			};
		},
		onLoad() {
			this.getproductlist()
			this.tabqh()
		},
		methods: {
			tabqh(index){
				this.sign = !index?0:index
				this.products = this.productlist[this.sign].products
				this.tags = this.productlist[this.sign].products.tags
			},
			async getproductlist(){
				let res = await new Promise((ok,no)=>{
					uni.request({
						url:'http://shop.datong0.com/api/wechat/product/list',
						success(val) {
							ok(val.data)
						}
					})
					
				})
				console.log(res.data);
				this.productlist =  res.data
				this.products = this.productlist[this.sign].products 
				this.tags = this.productlist[this.sign].products.tags
				
			},
			changeIndicatorDots(e) {
				this.indicatorDots = !this.indicatorDots
			},
			changeAutoplay(e) {
				this.autoplay = !this.autoplay
			},
			intervalChange(e) {
				this.interval = e.target.value
			},
			durationChange(e) {
				this.duration = e.target.value
			}
		}
	}
</script>

<style lang="less">
	@import url('exam.less');
	.uni-margin-wrap {
			width: 690rpx;
			width: 100%;
		}
		.swiper {
			height: 300rpx;
		}
		.swiper-item {
			display: block;
			height: 300rpx;
			line-height: 300rpx;
			text-align: center;
		}
		.swiper-list {
			margin-top: 40rpx;
			margin-bottom: 0;
		}
		.uni-common-mt {
			margin-top: 60rpx;
			position: relative;
		}
		.info {
			position: absolute;
			right: 20rpx;
		}
		.uni-padding-wrap {
			width: 550rpx;
			padding: 0 100rpx;
		}
</style>